<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<img src="../img/1.jpg" id="slid" alt="" width="400px" height="400px">
</body>
</html>
<script type="text/javascript">
    var sum = 1;
    function print() {
        var slid = document.getElementById("slid")
        slid.src="../img/" +sum+".jpg"
        sum++;
        if (sum > 4){
            sum =1;
        }
    }
    window.setInterval(print,1000);
</script>